//
//  CostReportContentCell.m
//  StarOrangeStaff
//
//  Created by lshenrong on 2020/7/20.
//  Copyright © 2020 lshenrong. All rights reserved.
//

#import "CostReportContentCell.h"
#import "InputTempletTwelveTableViewCell.h"

@interface CostReportContentCell ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView *tableView;

@property (nonatomic,strong) UILabel *tableViewTitleLbl;
@property (nonatomic,strong) UILabel *sectionTitleLbl;

@end

@implementation CostReportContentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self!=nil){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.tableView];
        [self.contentView addSubview:self.tableViewTitleLbl];

        self.tableView.bounces = NO;
        self.tableView.scrollEnabled = NO;
        self.tableView.layer.cornerRadius = 10.0;
        self.tableView.layer.masksToBounds = YES;
        self.tableView.layer.borderWidth = 1;
        self.tableView.layer.borderColor = kAppBackgoundColor.CGColor;
        self.tableView.backgroundColor = kBlackColor;
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX);
            make.top.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX * 4);

            make.right.bottom.mas_equalTo(self.contentView).mas_offset(-kMarginOffsetX);

        }];
        self.tableViewTitleLbl.text = @"车牌号";
        
        [self.tableViewTitleLbl mas_updateConstraints:^(MASConstraintMaker *make) {
             make.left.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX);
            make.top.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX );

        }];
        
    }
    return self;
}

#pragma mark - Table view data source

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 50.00f;
}



//section头部视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc]init];
    [view addSubview:self.sectionTitleLbl];
    [self.sectionTitleLbl mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(view).mas_offset(kMarginOffsetX);
        make.centerY.mas_equalTo(view.mas_centerY);
    }];
    view.backgroundColor = [UIColor colorWithRGB:0xFFF6EC alpha:0.8];
    
    
    return view;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    InputTempletTwelveTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"InputTempletTwelveTableViewCellIdentifier"];
    cell.placeholder = @"请输入金额";
    if (indexPath.row == 0) {
        [cell setCellTitle:@"租车费用"];
    }else if (indexPath.row == 1) {
        [cell setCellTitle:@"停车费"];
    }else if (indexPath.row == 2) {
        [cell setCellTitle:@"用餐费"];
    }else if (indexPath.row == 3) {
        [cell setCellTitle:@"加班费"];
    }else if (indexPath.row == 4) {
        [cell setCellTitle:@"饮品费"];
    }else if (indexPath.row == 5) {
        [cell setCellTitle:@"其他费用"];

    }

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
     return 50;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return   1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 6;
}


- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [UIConfigure tableViewFromFactory];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0)];
        [_tableView registerClass:[InputTempletTwelveTableViewCell class] forCellReuseIdentifier:@"InputTempletTwelveTableViewCellIdentifier"];
        
    }
    return _tableView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

MACRO_UILabel_LazyloadNoTextWithPFCGMediumFont(tableViewTitleLbl, kBlackColor, 16)
MACRO_UILabel_LazyloadWithPFCGFont(sectionTitleLbl, @"5月20日", kOrangeColor, 15)


@end
